/* -------------------------------------------------------------------------- *
   TestWinUnit - Maria Blees (maria.blees@microsoft.com)

   File: ErrorHandlerTest.cpp
   Contains tests for the various methods of application error handling in 
   WinUnit.exe. Generally turned off because we don't want failing tests.
 * -------------------------------------------------------------------------- */

#include "WinUnit.h"

#if 0

#include <assert.h>

#pragma warning(push)
#pragma warning (disable: 4702)

#pragma region Test for terminate()

class MyClass1
{
public:
    ~MyClass1() 
    { 
        WIN_ASSERT_FAIL(_T("stuff")); 
#pragma warning ( suppress : 4722)
    }
};

BEGIN_TEST(DestructorThrowsExceptionInUnwindTest)
{
    try
    {
        MyClass1 myClass1;
        WIN_ASSERT_FAIL(_T("other stuff"));
    }
    catch(...)
    {
        WIN_TRACE(_T("In catch..."));
    }
}
END_TEST

#pragma endregion

#pragma region Handled structured exception tests

BEGIN_TEST(AccessViolationTest)
{
    int* p = NULL;
#pragma warning ( suppress : 6011)
    *p = 5;
}
END_TEST

#pragma endregion

#pragma region Unhandled exception tests

void thrashVar(int *i)
{
    i[0] = 4;
    i[1] = 4;
}

BEGIN_TEST(TrashStackVariable)
{
    int stackvar;
    char stackarray[4];
    thrashVar(&stackvar);
    while (stackvar)
#pragma warning (suppress: 6386)
        stackarray[stackvar--] = 0;
}
END_TEST

#pragma endregion

#pragma region Test for _set_error_mode

BEGIN_TEST(CrtSetErrorModeTest)
{
    assert(0);
}
END_TEST

#pragma endregion

#pragma warning(pop)

#endif // 0